package com.rongshu.view.home.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.home.contract.LookMoreRecommendView;
import com.rongshu.view.home.entity.PeopleRecommendRespose;
import com.rongshu.view.home.entity.RecomendMsg;

import java.util.List;

import rx.Subscriber;
import rx.functions.Func1;

public class LookMoreRecommendPresenter extends BasePresenter<LookMoreRecommendView> {

    public LookMoreRecommendPresenter(Context context) {
        super(context);
    }

    /**
     * 获取更多推荐语
     */
    public void getMoreRecommendMsg(int contribute_id, int contribute_type,
                                    int pageIndex, int pageSize, String sign) {
        RetorfitService.getMoreRecommendMsg(contribute_id, contribute_type, pageIndex, pageSize, sign)
                .map(new Func1<RecomendMsg, List<RecomendMsg.ResponseBean>>() {
                    @Override
                    public List<RecomendMsg.ResponseBean> call(RecomendMsg recomendMsg) {
                        return recomendMsg.getResponse();
                    }
                })
                .subscribe(new Subscriber<List<RecomendMsg.ResponseBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(List<RecomendMsg.ResponseBean> responseBeans) {
                        if (getView() != null) {
                            getView().onLookMoreRecommend(responseBeans);
                        }
                    }
                });
    }
}
